<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
	xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
<head th:include="inc/home::header">
</head>
<link type="text/css" th:href="@{/css/content.css}" rel="stylesheet" />
<body>
	<!--返回-->
	<div class="back"   onclick="loadPage('/planType')">
		<img src="images/back.png" />
	</div>
	<div class="head-top">
		<div th:include="header :: header"></div>
	</div>
	<div class="header-title">
		<span th:text="${title}">添加用户</span>
	</div>
	<div class="spare-a">
		<div class="save-bg">
			<a href="#" class="spare-tj" onclick="Save()">保 存</a>
		</div>

		<div class="spare-add">
			<form id="planTypeForm">

				<input type="text" readonly="readonly" style="display: none"
					name="id" />
				<ul>
					<li>
						<div class="spare-addl">
							<span class="star">*</span>类别名称：
						</div>
						<div class="spare-addr">
			             	<input type="text" class="spare-add-input"  id="typeName" name="typeName"/>
						</div>
					</li>
				</ul>
			</form>
		</div>

	</div>
</body>
<script th:inline="javascript">  
/*<![CDATA[*/  
  function verifyNull(obj){
	
		if(obj == null||obj.val()==""||obj.val()=="请选择"){
			top.$.Zebra_Dialog('<div class="prompt"><div class="warning-icon"></div><div class="success-title">输入的内容不能包含空</div></div>', {
				'title':'提示',
	 	         'buttons':['确定']
		     });
			return false;
		}
	return true;
}      
 function getData(){
	if(!verifyNull($("#typeName"))){
 		return false;
 	}
	return true;
 }
        
 
 function Save(){
		var validate=getData();
		  if(!validate){
			 return false;
		 }
	   var data= getDataJson("planTypeForm");
	   var obj = JSON.stringify(data);
      AjaxWebTableInfo("/planType/saveOrUpdate",data);
	 }
	      
	function AjaxWebTableInfo(url , obj){
		 $.ajax({
		     type: "post",
		     dataType: "json",
		     url: url,
		     data:obj,
		     success: function (data, status) {
		    	 		$.Zebra_Dialog(
								'<div class="prompt"><div class="success-icon"></div><div class="success-title">保存成功</div></div>',
								{
									'title' : '提示',
									'show_close_button' : false,
									'buttons' : [ {
										caption : '确定',
										callback : function() {
											
												loadPage("/planType");
											
										}
									} ]
								});
		     },
		     error: function (data) {
		    	 $.Zebra_Dialog('<div class="prompt"><div class="error-icon"></div><div class="success-title">保存失败!</div></div>', {
			            'title':'提示',
			            'buttons':['确定']
			         });
		     }
		 });	
	}

 
 
 
 
 
 
var planType = [[${planType}]];  
if(planType!=null){
    loadData(planType);
}

  
    
/*]]>*/  
</script>
</html>
